filter_var
Filter a variable using a specific filter
filter_var()
function filters variables through the specified filter.
If successful, the filtered data is returned, and if failed, false.
<?php if(!filter_var("someone@example....com", FILTER_VALIDATE_EMAIL)) { echo("E-mail is not valid"); } else { echo("E-mail is valid"); } ?>
输出类似:
E-mail is not valid
filter_var ( variable , filter , options )
parameter | describe |
---|---|
variable | Required. Specify the variables to be filtered. |
filter | Optional. Specifies the ID of the filter to be used. |
options | Specifies an array containing flags/options. Check each filter for possible flags and options. |